define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'wddj/evaluation/evaluation/index' + location.search,
                    details_url: 'wddj/evaluation/evaluation/details',
                    table: 'wddj_order_evaluation',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'order.city', title: __('Order.city'), operate: 'LIKE'},
                        {field: 'order.order_no', title: __('Order.order_no'), operate: 'LIKE'},
                        {field: 'agent.name', title: __('Agent.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'agent.mobile', title: __('Agent.mobile'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'order.from_address', title: __('Order.from_address'), operate: 'LIKE'},
                        {field: 'order.to_address', title: __('Order.to_address'), operate: 'LIKE'},
                        {field: 'payments.pay_time', title: __('Payments.pay_time'), operate: false},
                        {field: 'satisfaction_status', title: __('Satisfaction_status'), searchList: {"1":__('Satisfaction_status 1'),"2":__('Satisfaction_status 2')}, formatter: Table.api.formatter.status},
                        {field: 'remarks', title: __('Remarks'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
                            buttons: [
                                {
                                    name: 'details',
                                    text: __('查看详情'),
                                    title: __('查看详情'),
                                    classname: 'btn btn-xs btn-info btn-dialog',
                                    icon: 'fa',
                                    extend: 'data-area=["100%","100%"]',
                                    url: 'wddj/evaluation/evaluation/details',
                                },
                            ]
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        details: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
